<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

		<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.js"></script>
		 <script type="text/javascript" charset="utf-8">
			window.UEDITOR_HOME_URL = "/static/ueditor/";
			window.onload=function(){
				window.UEDITOR_CONFIG.initialFrameHeight=300;//编辑器的高度
			   	window.UEDITOR_CONFIG.initialFrameWidth=800;//编辑器的宽度
			   	 editor = new UE.ui.Editor({
					imageUrl : '/Editor/uploadImage',
					fileUrl : '/Editor/uploadFile',
					imagePath : '',
					filePath : '',
					imageManagerUrl:'/Editor/imageManage', //图片在线管理的处理地址
					imageManagerPath:'/'
				});
				editor.render("message_content");
			}
		</script>
	<style type="text/css">
		.hidden{display: none};
		
	</style>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
		<title>大波</title>

	</head>
	<body>
		<div>
				<?php echo ($article['article_content']); ?>
				
				<a href="/admin/message/add/id/$article['id']"></a>
				<input id="show_message_box_btn" type="button" value="留言">
				
				<div id="message_box" class="hidden">
					<textarea id="message_content" name="message_content"></textarea>
					<input type="submit" value="发表" id="submit">
			    </div>
					
				<input type="hidden" value="<?php echo ($article["id"]); ?>" name="message_id" id="message_id" />

				
				
				
					<div>
						<table id="message_table">
							<thead>
		                      	<tr>
		                          	<th>留言者</th>
		                         	<th>留言内容</th>
		                          	<th>留言时间</th>
		                      	</tr>
                  			</thead>
                  			<tbody>
								<?php if(is_array($message_list)): $i = 0; $__LIST__ = $message_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><tr>
										<td><?php echo ($data['message_name']); ?></td>
										<td><?php echo ($data['message_content']); ?></td>
										<td><?php echo ($data['message_time']); ?></td>
									</tr><?php endforeach; endif; else: echo "" ;endif; ?>
							</tbody>
						</table>
						<a href="<?php echo U('admin/message/sortsc','order=0');?>">升</a>
						<a href="<?php echo U('admin/message/sortsc','order=1');?>">降</a>
					</div>
					
				
	    </div>

<script src="/static/assets/js/jquery.min.js"></script>
<script type="text/javascript">
	$(function () {
		$('#show_message_box_btn').click(function () {
			if($("#message_box").hasClass("hidden")){
				$("#message_box").removeClass("hidden");
			} else {
				$("#message_box").addClass("hidden");
			}
		});
	});

	$(function () {
		$('#submit').click(function () {
			json_data = {};
			json_data.content = editor.getPlainTxt();
			json_data.id = $('#message_id').val();
			
			saveMessage(json_data);    
							
			})
		})

	function saveMessage(json_data) {
		$.ajax({
			url :       "/admin/message/add",
			type :      "post",
			dataType :  "json",
			data : json_data,
			success: function(data) {

					

					var tr ="<tr><td>"+data.message_name+"</td><td>"+data.message_content+"</td><td>"+data.message_time+"</td></tr>";
					$('#message_table').append(tr);

					
				
			}
		});
	}

	function sortBy (time, order) {

	}
	

</script>
	</body>
</html>